<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>库存管理系统-客户系统</title>
		<link rel='icon' href='../favicon.ICO' type='image/x-ico' /> 
		<!--vendor css-->
		<link rel="stylesheet" href="../assets/vendor/bootstrap/css/bootstrap.min.css" />
		<!--plug-in css -->
		<link rel="stylesheet" href="../assets/vendor/bootstrap/css/bootstrap-table.css" />
		<!--common css-->
		<link rel="stylesheet" href="../assets/css/common.css" />
		<link rel="stylesheet" href="../assets/css/theme.css" />
		<!--us css-->
		<link rel="stylesheet" href="../assets/css/styles.css" />
		<link rel="stylesheet" href="../assets/css/index.css" />
		<link rel="stylesheet" href="orders.css" />
		<link rel="stylesheet" href="print.css" />
	</head>
	<body>

	<div id="printOrderTable" class="width-p100 print-list" style="width: 1000px;height: 465px;">
		<h3 class="text-center h-title">上海明承电器设备有限公司</h3>
		<h3 class="text-center h-title">
			<span class="invoice-title-sec">销&nbsp;&nbsp;售&nbsp;&nbsp;发&nbsp;&nbsp;货&nbsp;&nbsp;单</span>
		</h3>
		<!--<div class="col-sm-4">
			<div class="col-sm-5 text-left">
				发票单号：
			</div>
			<div class="col-sm-7 text-left">
				<span id="taxNumberpt"></span>
			</div>
		</div>
		<div class="col-sm-4">
			<div class="col-sm-5 text-left">
				发货日期：
			</div>
			<div class="col-sm-7 text-left">
				<span id="deliveryTimept"></span>
			</div>
		</div>
		<div class="col-sm-4">
			<div class="col-sm-5 text-left">
				客户名称：
			</div>
			<div class="col-sm-7 text-left">
				<span id="userIdpt"></span>
			</div>
		</div>
		<div class="col-sm-4">
			<div class="col-sm-5 text-left">
				联系人：
			</div>
			<div class="col-sm-7 text-left">
				<span id="realNamept"></span>
			</div>
		</div>
		<div class="col-sm-4">
			<div class="col-sm-5 text-left">
				联系电话：
			</div>
			<div class="col-sm-7 text-left">
				<span id="userPhonept"></span>
			</div>
		</div>
		<div class="col-sm-4">
			<div class="col-sm-5 text-left">
				手机：
			</div>
			<div class="col-sm-7 text-left">
				<span></span>
			</div>
		</div>
		<div class="col-sm-4">
			<div class="col-sm-5 text-left">
				运输方式：
			</div>
			<div class="col-sm-7 text-left">
				<span id="fareTypept"></span>
			</div>
		</div>
		<div class="col-sm-4">
			<div class="col-sm-5 text-left">
				付款条件：
			</div>
			<div class="col-sm-7 text-left">
				<span></span>
			</div>
		</div>
		<div class="col-sm-12">
			<div class="col-sm-2 text-left invoice-left-wd">
				收货地址：
			</div>
			<div class="col-sm-8 text-left">
				<span id="shoppingAddresspt"></span>
			</div>
		</div>-->
		<table class="table print-table">
			<tbody>
				<tr>
					<td>客户代码：</td>
					<td><span id="userIdpt"></span></td>
					<td>联系人：</td>
					<td><span id="realNamept"></span></td>
					<td>联系电话：</td>
					<td><span id="userPhonept"></span></td>


				</tr>
				<tr>
					<td colspan="1">收货地址：</span></td>
					<td colspan="1"><span id="shoppingAddresspt"></span></td>

					<td>发货日期：</td>
					<td><span id="deliveryTimept"></span></td>
					<td>订单编号：</td>
					<td><span id="fareTypept"></span></td>
				</tr>

			</tbody>
		</table>
		<table class="table table-striped">
			<thead>
			<tr>
				<th>序号</th>
				<th>物料名称</th>
				<th>品牌</th>
				<th>规格</th>
				<th>单位</th>
				<th>数量</th>
				<th>单价</th>
				<th>金额</th>
			</tr>
			</thead>
			<tbody id="printOrderDetailList">
			<!--<tr>
                <td id="productIdpt"></td>
                <td id="productNamept"></td>
                <td id="productVersionpt"></td>
                <td>套</td>
                <td id="numberpt"></td>
                <td id="singlePricept"></td>
                <td id="totalPricept"></td>
            </tr>
            <tr>
                <td>合计数量</td>
                <td colspan="3"></td>
                <td id="allNumber"></td>
                <td></td>
                <td id="allTotal"></td>
            </tr>
            <tr>
                <td>合计金额</td>
                <td colspan="6" id="allTotalUP">

                </td>
            </tr>
            <tr>
                <td>备注</td>
                <td colspan="6">

                </td>
            </tr>-->
			</tbody>
		</table>
		<table class="table print-table">
			<tbody>
				<tr>
					<td>经办人：</td>
					<td><span class="item-span">李国明</span></td>
					<td>审批人：</td>
					<td colspan="1"><span class="item-span">李国明</span></td>
					<td colspan="1">打印日期：</td>
					<td colspan="3"><span class="item-span" id="printDate"></span></td>
					<td>实收台数：</td>
					<td><span id="totalNumber"></span></td>
					<td>收货人：</td>
					<td><span id="realNamept2"></span></td>

				</tr>
				<tr>

				</tr>
				<tr>
					<td colspan="1">电话热线：</td>
					<td  colspan="3"><span class="item-span">400-0210-0380</span></td>
					<td colspan="1">地址：</td>
					<td colspan="3"><span class="item-span">上海市宝山区锦秋路2684号</span></td>
					<td colspan="1">公司网站：</td>
					<td colspan="7"><span class="item-span">http://www.021ele.com<!--<a href="http://www.021ele.com" target="_blank">http://www.021ele.com</a>--></span></td>

				</tr>
				<tr>

				</tr>
				<tr>

				</tr>
			</tbody>
		</table>
		<!--<div class="width-p100 item-div">
			<label for="" class="item-label">
				经办人：
				<span class="item-span">李国明</span>
			</label>
			<label for="" class="item-label">
				审批人：
				<span class="item-span">李国明</span>
			</label>
			<label for="" class="item-label">
				打印日期：
				<span class="item-span" id="printDate"></span>
			</label>
			<label for="" class="item-label">
				实收台数
				<span class="item-span"> </span>
			</label>
			<label for="" class="item-label">
				收货人
				<span class="item-span"> </span>
			</label>
		</div>
		<div class="width-p100 item-div">
			<label for="" class="item-label">
				电话热线：
				<span class="item-span">400-0210-0380</span>
			</label>
			<label for="" class="item-label">
				公司网站：
				<span class="item-span"><a href="http://www.021ele.com" target="_blank">www.021ele.com</a></span>
			</label>
			<label for="" class="item-label">
				地址：
				<span class="item-span">上海市宝山区锦秋路1317号</span>
			</label>
		</div>-->
	</div>
	<div class="width-p100 btn-div">
		<button id="btnPrintOrder" type="button" class="btn btn-primary">打印</button>
	</div>
		<!--vendor js-->
		<script type="text/javascript" src="../assets/vendor/jquery/jquery.min.js"></script>
		<script type="text/javascript" src="../assets/vendor/bootstrap/js/bootstrap.min.js"></script>
		<!--plug-in js -->
		<script type="text/javascript" src="../assets/vendor/bootstrap/js/bootstrap-table.js"></script>
		<script type="text/javascript" src="../assets/js/jquery-migrate-1.2.1.min.js"></script>
		<script type="text/javascript" src="../assets/js/jquery.jqprint-0.3.js"></script>
		<!--common js-->
		<script type="text/javascript" src="../assets/js/gobalInit.js"></script>
		<script type="text/javascript" src="../assets/js/util.js"></script>
		<script type="text/javascript" src="../assets/js/default.js"></script>
		<!--us js-->
		<script type="text/javascript" src="../assets/js/index.js"></script>
		<script type="text/javascript">
			$(function () {
                var tgid=getUrlParam("tgid");
                if(tgid!=null && tgid!=""){
                    getPrintMesDetail(tgid);
                }
                btnPrintOrder();
            });
            //打印订单信息
            function btnPrintOrder(){
                $("#btnPrintOrder").on('click',function(){
                    $("#printOrderTable").jqprint();
                    /*window.location.reload();*/
                    /*{
                        importCSS: true, //true表示引进原来的页面的css，默认是true。（如果是true，先会找$(“link[media=print]“)，若没有会去找$(“link”)中的css文件）
                            printContainer: true//表示如果原来选择的对象必须被纳入打印（注意：设置为false可能会打破你的CSS规则）。
                    }*/
                    /*printHtml($("#printOrderTable"));
                    window.location.reload();*/
                });
            };
			/*打印单详情*/
            function getPrintMesDetail(tgid){
                if(tgid!=null && tgid!=""){
					/*var datarows=testoneitem;
					 if(datarows!=null){
					 btnPrintOrder();
					 $("#printModal").modal("show");
					 }else{
					 consoleMes($("#manageContent"),2000,"warning","无法获取数据，请刷新重试！");
					 }*/
                    $.post(
                        gobalServer+"order/selectOne",
                        {"orderId":tgid},
                        function(backData){
                            if(backData.statusCode==200){
                                var datarows=backData.object;
                                if(datarows!=null){
                                    $("#taxNumberpt").text(datarows.taxNumber);
                                    var fareTime="";
                                    if(datarows.fareTime!=null && datarows.fareTime!="" && datarows.fareTime!=0){
                                        fareTime=formatDateTimeYMDHMS(datarows.fareTime);
                                        fareTime=fareTime.substr(0,fareTime.indexOf(" "));
                                    }
                                    $("#deliveryTimept").text(fareTime);


									/*$("#totalNumber").text(datarows.number);*/
									$("#userIdpt").text(datarows.userId);
                                    $("#realNamept").text(datarows.realName);
									/*$("#realNamept2").text(datarows.realName);*/
                                    $("#userPhonept").text(datarows.userPhone);
                                    $("#fareTypept").text(datarows.orderId);
                                    $("#shoppingAddresspt").text(datarows.shoppingAddress);
									/*$("#productIdpt").text(datarows.productId);
									 $("#productNamept").text(datarows.productName);
									 $("#productVersionpt").text(datarows.productVersion);
									 $("#numberpt").text(datarows.number);
									 $("#singlePricept").text(datarows.singlePrice.toFixed(2));*/
									/*$("#totalPricept").text(datarows.totalPrice.toFixed(2));
									 $("#allNumber").text(datarows.number);
									 $("#allTotal").text(datarows.totalPrice.toFixed(2));
									 $("#allTotalUP").text(digitUppercase(datarows.totalPrice.toFixed(2)));*/
                                    var printDate = timeStamp2String(new Date());
                                    printDate=printDate.substr(0,printDate.indexOf(" "));
                                    $("#printDate").text(printDate);
                                    if(datarows.orderId!=null && datarows.orderId!=""){
                                        getPrintOrderDetailList(datarows.orderId,datarows.totalPrice,datarows.orderRemark);
                                    }
									/*btnPrintOrder();
									 $("#printModal").modal("show");*/
                                }else{
                                    consoleMes($("#manageContent"),2000,"warning","无法获取数据，请刷新重试！");
                                }
                            }else{
                                consoleMes($("#manageContent"),2000,"warning",backData.msg);//success、info、warning、danger

                            }
                        }
                    );

                }else{
                    consoleMes($("#manageContent"),2000,"warning","无法查看，请刷新页面重试！");//success、info、warning、danger
                }
            };
			/*获取打印订单详情*/
            function getPrintOrderDetailList(tid,totalPrice,orderRemark) {
                if(tid!=null && tid!=""){
                    $.post(
                        gobalServer+"order/selectOrderDetailByOrderId",
                        {"orderId":tid},
                        function(backData){
                            if(backData.statusCode==200){
                                var datarows=backData.commonList;
                                $("#printOrderDetailList").empty();
                                if(datarows.length>0){
                                    var totalNum=0;
                                    $.each(datarows,function (i,item) {
                                        $indexNum=$("<td>").text(i+1);
                                        $productId=$("<td>").text(item.productId);
                                        $productName=$("<td>").text(item.productName);
                                        $productBrand=$("<td>").text(item.productBrand);
                                        $productVersion=$("<td>").text(item.productVersion);
                                        $unit=$("<td>").text("套");
                                        $number=$("<td>").text(item.number);
                                        totalNum+=item.number;
                                        $singlePrice=$("<td>").text(item.singlePrice.toFixed(2));
                                        $totalPrice=$("<td>").text((item.singlePrice*item.number).toFixed(2));
                                        $tr=$("<tr>");
                                        $tr.append($indexNum,$productName,$productBrand,$productVersion,$unit,$number,$singlePrice,$totalPrice);
                                        $("#printOrderDetailList").append($tr);
                                    });
                                    $td1=$("<td>").text("合计：");
                                    $td2=$("<td>").attr({"colspan":4}).text(digitUppercase(totalPrice.toFixed(2)));
                                    $number=$("<td>").text(totalNum);
                                    $td3=$("<td>");
                                    $totalPrice=$("<td>").text(totalPrice.toFixed(2));
                                    $tr1=$("<tr>");
                                    $tr1.append($td1,$td2,$number,$td3,$totalPrice);
                                    $("#printOrderDetailList").append($tr1);
                                    $td3=$("<td>").text("合计金额");
                                    $totalPriceUP=$("<td>").attr({"colspan":6}).text(digitUppercase(totalPrice.toFixed(2)));
                                    $tr2=$("<tr>");
                                    $tr2.append($td3,$totalPriceUP);
                                   /* $("#printOrderDetailList").append($tr2);*/
                                    $td4=$("<td>").text("备注");
                                    $remark=$("<td>").attr({"colspan":7}).text(orderRemark);
                                    $tr4=$("<tr>");
                                    $tr4.append($td4,$remark);
                                    $("#printOrderDetailList").append($tr4);
                                }
                                btnPrintOrder();
                                $("#printModal").modal("show");
                            }else{
                                consoleMes($("#manageContent"),2000,"warning",backData.msg);//success、info、warning、danger

                            }
                        }
                    );
                }else {
                    consoleMes($("#manageContent"),2000,"warning","无法获取订单详情信息，请刷新页面重试！");//success、info、warning、danger
                }
            }
		</script>
	</body>
</html>
